package com.heima.wemedia.listen;

import com.heima.common.constants.message.NewsAutoScanConstants;
import com.heima.wemedia.service.WmNewsAutoScanService;
import com.heima.wemedia.service.WmNewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import sun.rmi.runtime.Log;

@Slf4j
@Component
public class WemediaNewsAutoListener {
    @Autowired
    WmNewsAutoScanService wmNewsAutoScanService;
    @Autowired
    WmNewsService wmNewsService;


    /**
     * 根据文章id调用文章审核功能
     * @param id
     */
    @RabbitListener(queuesToDeclare = @Queue(NewsAutoScanConstants.WM_NEWS_AUTO_SCAN_QUEUE))
    public void newsAudit(String id){
        log.info("接受到审核文章的Id===={}",id);
        wmNewsAutoScanService.autoScanWmNews(Integer.valueOf(id));
        log.info("文章审核完毕! 文章Id===={}",id);

    }
}
